<h1>Countries of origin</h1>

<%
	country_list = Array.new
	country_count = Array.new
	country_values = Array.new
%>

<% @countries.each do |country| 
		country_list << country.iso_code
		if country.entities_count.to_i > 500
			country_count << '500'.to_i
		else
			country_count << country.entities_count.to_i
		end
	 end 
	
	max_value = country_count.sort.last.to_i

	multiply_factor = 100 / max_value.to_f


	country_count.each do |c|
		country_values << (c.to_i * multiply_factor).to_i
	end	
	
	%>

<% if country_values.size > 0 %>
	<div class="chart">
	<%= google_chart("440x220", {:type => "map", :map_area => "world", :data => country_values, :data_encoding => "numbers", :country_codes => country_list, :country_default_color => "ffffff", :country_min_colour => "edf0d4", :country_max_color => "13390a" }) %>
	</div>
	<div class="selected_data">
	
	</div>
	<div style="clear: both;">&nbsp;</div>

	<ul class="country_list">
		<% for country in @countries %>
		<% if country.entities.count > 0 %>
		<% f = (10 + (country.entities.count / 3)).to_int %>
		<% f = 40 if f > 40 %>
			<li><%= link_to country.name, museum_country_path(@museum, country), {:style=> "font-size: #{f}px;"} %></li>
		<% end %>
		<% end %>
	</ul>
<% else %>
	<p>There isn't any information about countries for this museum yet.</p>
<% end %>